package com.shop2cn.iapi.sqsynctrade.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import com.ymttest.business.service.shenqi.*;
import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.shenqisettlement.parameter.bean.AgentProductBean;
import com.shop2cn.iapi.sqoptrade.parameter.enums.CancelOrderTypeEnum;
import com.shop2cn.iapi.sqoptrade.parameter.enums.PromotionTypeEnum;
import com.shop2cn.iapi.sqoptrade.parameter.req.ConfirmApplyRefundReq;
import com.shop2cn.iapi.sqoptrade.parameter.req.PlaceOrderReq;
import com.shop2cn.iapi.sqoptrade.parameter.vo.CatalogApportionVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.OrderItemVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.SellerPromotionVo;
import com.shop2cn.iapi.sqoptrade.parameter.vo.UbuyUserVo;
import com.shop2cn.iapi.sqoptrade.resp.Order;
import com.shop2cn.iapi.sqoptrade.resp.TradingServiceResp;
import com.shop2cn.iapi.sqsynctrade.service.TradingSyncService;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AccountCallServiceV2;
import com.ymttest.business.service.SQPayGateWayCallService;
import com.ymttest.business.service.shenqi.bean.PackageInfoByCatalogIdListResponse;
import com.ymttest.business.service.shenqi.bean.ShenqiUserSet;
import com.ymttest.database.sharding.db.sharding.model.OrderDetailPo;
import com.ymttest.database.sharding.db.sqlwapper.shenqi.OrderShardingWapper;
import com.ymttest.database.sqlwapper.DGUserWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;

/**
 * 同步指令接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_DGSQTradingSync {

	private static long autotest_goodsOwnerId = Long.valueOf(EnvSetup
			.getData("autotest_goodsOwnerId"));
	private static long cdfMembergoodsOwnerId = ShenqiUserSet.cdfMembergoodsOwnerId;
	private static long virtualCoinGoodsOwnerId = ShenqiUserSet.virtualCoinGoodsOwnerId;
	private static long multiCDFCodeGoodsOwnerId = ShenqiUserSet.multiCDFCodeGoodsOwnerId;
	private static long shenqiRiskControlGoodsOwnerId = ShenqiUserSet.shenqiRiskControlGoodsOwnerId;
	
	private static OrderShardingWapper wapper = new OrderShardingWapper();

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("同步指令接口");
	}

	@Before
	public void caseUp() {
		String accountid1;
		try {
			accountid1 = AccountCallServiceV2.getAccountId(20238699);
			AccountCallServiceV2.resetAccount(accountid1, new BigDecimal(
					9000000), new BigDecimal(0));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult("api/syncByCommand");
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_001() {
		Logger.start(true, "代购神器交易下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, autotest_goodsOwnerId,
							productBean.getCurrency());

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_002() {
		Logger.start(true, "代购神器交易下单,使用了折扣上调，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrder = SqTradingCallService
					.placeOrder2(BigDecimal.TEN, productBean, 1);

			long userId = placeOrder.getUserId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_003() {
		Logger.start(true, "代购神器交易下单支付并自动接单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			Logger.comment("前置数据准备结束");

			// 支付订单
			long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			Thread.sleep(3000);

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_004() {
		Logger.start(true, "代购神器交易下单支付并修改地址，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			Logger.comment("前置数据准备结束");

			// 支付订单
			long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());
			
			SqTradingCallService.changeOrderAddress(orderId, userId);

			Thread.sleep(3000);

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_005() {
		Logger.start(true, "代购神器交易下单支付，手动接单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			Logger.comment("前置数据准备结束");

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			// 通知订单身份证信息
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");

			String orderJson = "{\"orderId\":" + orderId
					+ ",\"businessType\":15}";
			YmatouEasyCall
					.setUrl("http://optrade.iapi.ymatou.com/api/Common/syncOrderIdCard");

			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_006() {
		Logger.start(true, "代购神器交易下单,买家取消订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			SqTradingCallService.cancelOrder(orderId,
					CancelOrderTypeEnum.BUYER_CANCEL_ORDER, userId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_008() {
		Logger.start(true, "代购神器接单后下单带salesman，goodsOwnerId取消订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.cancelOrder(orderId,
					CancelOrderTypeEnum.SELLER_CANCEL_ORDER, goodsOwnerId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_009() {
		Logger.start(true, "代购神器渠道商交易下单,多个商品，一个订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithMultiProsInOneOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_010() {
		Logger.start(true, "代购神器代理商交易下单,多个商品，一个订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithMultiProsInOneOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_011() {
		Logger.start(true, "代购神器发货,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);
//			for (int i = 0; i < 30; i++) {
//				
//				AgentProductBean productBean = new AgentProductBean();
//				productBean.setProductId("p1536880");
//				productBean.setSellerId(500019955);
//				productBean.setSellerLoginId("培培的代理店铺");
//				String[] catalogs = {"c2531517"};
//				productBean.setCatalogList(Arrays.asList(catalogs));
//				
//				TradingServiceResp placeOrderResp = TradingForDGSQCallService
//						.placeOrder(productBean, 500019955);
//
//				Long userId = placeOrderResp.getUserId();
//				long goodsOwnerId = placeOrderResp.getOrderList().get(0)
//						.getOrderPo().getGoodsOwnerId();
//				long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
//				BigDecimal totalPrice = placeOrderResp.getPayableAmount();
//
//				// 支付订单
//				Long thirdTradingId = TradingForDGSQCallService.payOrder(userId,
//						placeOrderResp.getTradingId());
//
//				// 支付网关支付回调交易
//				SQPayGateWayCallService.DGSQNotifyCall(
//						String.valueOf(thirdTradingId),
//						totalPrice.subtract(BigDecimal.ZERO).toString(),
//						userId.intValue(), BigDecimal.ZERO.toPlainString());
//
//				TradingSyncService.getSyncResult(orderId);
//				Thread.sleep(3000);
//
//				// 接单
//				TradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
//				TradingSyncService.getSyncResult(orderId);
//				
//				Thread.sleep(5000);
//			}
			
			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			Thread.sleep(5000);
			
			// 神器订单发货
			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId,
					1L, null);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_012() {
		Logger.start(true, "代购神器代理商交易下单,上调折扣，多个商品，多个订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(BigDecimal.TEN, productBean, 1);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_013() {
		Logger.start(true, "代购神器代理商交易下单,下调折扣，多个商品，多个订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(new BigDecimal("-10.00"), productBean, 1);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_014() {
		Logger.start(true,
				"代购神器代理商交易下单,下调折扣，多个商品，多个订单，下单完成后，再次修改折扣验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(new BigDecimal("-10.00"), productBean, 1);

			long userId = placeOrderResp.getUserId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.changeDiscount(orderId, sellerId,
					BigDecimal.TEN, BigDecimal.ONE);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_015() {
		Logger.start(true, "代购神器代理商交易下单,下单完成后，修改折扣验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			long userId = placeOrderResp.getUserId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.changeDiscount(orderId, sellerId,
					BigDecimal.TEN.negate(), BigDecimal.ONE);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			
			Thread.sleep(3000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_016() {
		Logger.start(true, "代购神器直销商交易下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId());

			long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int)userId, BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_017() {
		Logger.start(true, "神器订单添加备注,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(productBean, autotest_goodsOwnerId);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long sellerId = resp.getOrderList().get(0).getSellerId();
			long userId = resp.getUserId();
			
			Thread.sleep(2000);
			
			SqTradingCallService.operateSellerMemo(orderId, sellerId, 0);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			
			Thread.sleep(3000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_018() {
		Logger.start(true, "神器订单更新备注,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(productBean, autotest_goodsOwnerId);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long sellerId = resp.getOrderList().get(0).getSellerId();
			long userId = resp.getUserId();
			
			Thread.sleep(2000);
			
			SqTradingCallService.operateSellerMemo(orderId, sellerId, 1);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_019() {
		Logger.start(true, "神器订单下单，币种为CNY, 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.ZERO, autotest_goodsOwnerId,
					productBean.getCurrency());
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_020() {
		Logger.start(true, "神器订单下单，币种为外币, 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.ZERO, autotest_goodsOwnerId,
					productBean.getCurrency());
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_021() {
		Logger.start(true, "神器订单下单并支付，币种为CNY, 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
//
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) 500919671, 0, false);
			
//			AgentProductBean productBean = new AgentProductBean();
//			
//			productBean.setGoodsOwnerId(autotest_goodsOwnerId);
//			productBean.setCurrency("CNY");
//			productBean.setProductId("p4160670");
//			productBean.setCatalogList(Arrays.asList("c7069566"));
//			productBean.setSellerId(500919671);
//			productBean.setSellerLoginId("sgjsdfkl");
			
			String currency = productBean.getCurrency();

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.ZERO, 500919671,
					currency);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();
			BigDecimal totalPrice = resp.getPayableAmount();
			
			TradingSyncService.getSyncResult(orderId);
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					resp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int)userId, BigDecimal.ZERO.toPlainString(), currency);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_022() {
		Logger.start(true, "神器订单下单并支付，币种为外币, 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false, true);
			
			String currency = productBean.getCurrency();

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.ZERO, autotest_goodsOwnerId,
					currency);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();
			BigDecimal totalPrice = resp.getPayableAmount();
			
			TradingSyncService.getSyncResult(orderId);
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					resp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int)userId, BigDecimal.ZERO.toPlainString(), currency);

			Logger.comment("前置数据准备结束");
			
			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_023() {
		Logger.start(true, "神器订单下单，币种为CNY, 包含税费，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.ZERO, autotest_goodsOwnerId,
					productBean.getCurrency(), new BigDecimal("0.165321"));
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_024() {
		Logger.start(true, "神器订单下单，币种为CNY, 包含折扣，包含税费，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.TEN, autotest_goodsOwnerId,
					productBean.getCurrency(), new BigDecimal("0.16"));
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_025() {
		Logger.start(true, "代购神器代理商交易下单, 包含税费，下单完成后，修改折扣验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.TEN, autotest_goodsOwnerId,
							productBean.getCurrency(), new BigDecimal("0.25"));

			long userId = placeOrderResp.getUserId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.changeDiscount(orderId, sellerId,
					BigDecimal.TEN.negate(), BigDecimal.ONE);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_026() {
		Logger.start(true, "神器订单下单，币种为日币, 包含折扣，包含税费，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 2, false, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.TEN, 500058147,
					productBean.getCurrency(), new BigDecimal("0.16"));
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_027() {
		Logger.start(true, "代购神器继承代理，售价利润正好等于优惠金额，带客服，下单完成后，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createInheritedProxychain((int) mchId, false);
			
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeInheritedOrderMultiProduct(productBean, (int) mchId,
							4321, true);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();
			
			TradingSyncService.getSyncResult(orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), (int) userId,
					BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_028() {
		Logger.start(true, "神器创建砍价团参团订单,砍价团通知组团成功,ORDER_BIZ指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false);

			BargainGroupService.shenqiOpenGroup(bizId, productBean, false);

			// 参团
			TradingServiceResp placeOrder2 = BargainGroupService
					.shenqiJoinGroup(bizId, productBean, false);

			long orderId = placeOrder2.getOrderList().get(0).getOrderId();
			long userId = placeOrder2.getUserId();

			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, 3);
			
			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_029() {
		Logger.start(true, "神器创建砍价团参团订单,砍价团通知组团失败,ORDER_BIZ指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			BargainGroupService.shenqiOpenGroup(bizId, productBean, false);

			// 参团
			TradingServiceResp placeOrder2 = BargainGroupService
					.shenqiJoinGroup(bizId, productBean, false);

			long orderId = placeOrder2.getOrderList().get(0).getOrderId();
			long userId = placeOrder2.getUserId();

			Logger.comment("前置数据准备结束");

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, -3);
			
			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_030() {
		Logger.start(true, "神器订单下单，币种为CNY, 包含税费，支持线下支付，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.ZERO, autotest_goodsOwnerId,
					productBean.getCurrency(), new BigDecimal("0.165321"), true);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_031() {
		Logger.start(true, "神器订单下单，币种为CNY, 包含税费，买家同意线下支付，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.ZERO, autotest_goodsOwnerId,
					productBean.getCurrency(), new BigDecimal("0.165321"), true);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();
			
			SqTradingCallService.payOrder(userId, resp.getTradingId(), "wxsqBuyer", "200");

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_032() {
		Logger.start(true, "神器订单下单，币种为CNY, 包含税费，买手确认线下支付，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.ZERO, autotest_goodsOwnerId,
					productBean.getCurrency(), new BigDecimal("0.165321"), true);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();
			
			SqTradingCallService.payOrder(userId, resp.getTradingId(), "wxsqBuyer", "200");
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.confirmOfflinePay(orderId, autotest_goodsOwnerId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_033() {
		Logger.start(true, "代购神器直销商交易下单,包含虚拟库存，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId(), 2);

			long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_034() {
		Logger.start(true, "神器创建砍价团参团订单,使用了虚拟库存，砍价团通知组团成功,ORDER_BIZ指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			BargainGroupService.shenqiOpenGroup(bizId, productBean, true);

			// 参团
			TradingServiceResp placeOrder2 = BargainGroupService
					.shenqiJoinGroup(bizId, productBean, true);

			long orderId = placeOrder2.getOrderList().get(0).getOrderId();
			long userId = placeOrder2.getUserId();

			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, 3);
			
			Thread.sleep(5000);
			
			SqTradingCallService.ReduceSqProductStocks(orderId);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_035() {
		Logger.start(true, "神器创建砍价团参团订单,使用了虚拟库存，砍价团通知组团失败,ORDER_BIZ指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			// 开团
			TradingServiceResp openOrder = BargainGroupService.shenqiOpenGroup(
					bizId, productBean, false);

			Thread.sleep(5000);

			long openOrderId = openOrder.getOrderList().get(0).getOrderId();

			// 扣除开团库存
			SqTradingCallService.ReduceSqProductStocks(openOrderId);

			// 参团
			TradingServiceResp joinOrder2 = BargainGroupService
					.shenqiJoinGroup(bizId, productBean, true);

			Thread.sleep(5000);

			long orderId = joinOrder2.getOrderList().get(0).getOrderId();
			long userId = joinOrder2.getUserId();

			// 扣除参团库存
			SqTradingCallService.ReduceSqProductStocks(orderId);

			Logger.comment("前置数据准备结束");
	
			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);
			
			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, -3);
			
			Thread.sleep(5000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_036() {
		Logger.start(true, "订单支付,满减包邮，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			
			TradingServiceResp placeOrder = SqTradingCallService
					.placeOrderWithFreeFreight(productBean, true);

			long userId = placeOrder.getUserId();
			long tradingId = placeOrder.getTradingId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					tradingId);
			
			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrder
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), (int) userId,
					BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_037() {
		Logger.start(true, "神器代理购买订单交易下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 3, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, true);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_038() {
		Logger.start(true, "代购神器交易下单，使用订单别名,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 3, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithOrderAlias(productBean, "orderAlias+fsfsgsdf");

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_039() {
		Logger.start(true, "代购神器交易下单，渠道商使用商家优惠，造成负利润,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321L, BigDecimal.ZERO,
							20238699, productBean, autotest_goodsOwnerId, false);

			OrderItemVo orderItemVo1 = placeOrderReq.getOrderGroups().get(0)
					.getOrders().get(0).getOrderItems().get(0);
			orderItemVo1.setProdTaxRate(new BigDecimal("0.17"));
			// orderItemVo1.setProductNum(1);
			// orderItemVo1.setProductPrice(BigDecimal.TEN);

			OrderItemVo orderItemVo2 = SqTradingCallService
					.createOrderItemVo(productBean.getProductId(), productBean
							.getCatalogList().get(1));
			orderItemVo2.setProdTaxRate(new BigDecimal("0.47"));
			// orderItemVo2.setProductNum(1);
			// orderItemVo2.setProductPrice(BigDecimal.TEN);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo2);

			BigDecimal discount1 = orderItemVo1.getProductPrice().multiply(
					new BigDecimal(orderItemVo1.getProductNum()));

			BigDecimal discount2 = orderItemVo2.getProductPrice().multiply(
					new BigDecimal(orderItemVo2.getProductNum()));

			// 定义买手下的优惠商品信息list
			List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

			SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();

			sellerPromotion1.setAmountCondition(new BigDecimal(100));
			sellerPromotion1.setId(123456789);
			sellerPromotion1.setName("自动化商家优惠活动");

			sellerPromotion1.setPromotionValue(new BigDecimal(12));
			sellerPromotion1.setQtyCondition(4);

			sellerPromotion1.setReducedAmount(discount1.add(discount2));
			sellerPromotion1.setType(PromotionTypeEnum.ReduceIfAmountEnough);

			sellerPromotion1.setApportions(Arrays.asList(
					new CatalogApportionVo(productBean.getCatalogList().get(0),
							orderItemVo1.getProductNum()),
					new CatalogApportionVo(orderItemVo2.getCatalogId(),
							orderItemVo2.getProductNum())));

			sellerPromotionList.add(sellerPromotion1);

			placeOrderReq.getOrderGroups().get(0)
					.setSellerPromotionApportions(sellerPromotionList);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.callPlaceOrderService(placeOrderReq);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), (int) userId,
					BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_040() {
		Logger.start(true, "代购神器交易下单，多个境内商品，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(4321, BigDecimal.ZERO,
							20238699, productBean, (int) autotest_goodsOwnerId);

			placeOrderReq.setPayChannelType(2);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0).setDomesticProduct(true);

			OrderItemVo orderItemVo = SqTradingCallService.createOrderItemVo(
					productBean.getProductId(), productBean.getCatalogList()
							.get(1));

			orderItemVo.setDomesticProduct(true);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().add(orderItemVo);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.callPlaceOrderService(placeOrderReq);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_041() {
		Logger.start(true, "交易下单,带有ubuy信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			UbuyUserVo ubuyUserVo = new UbuyUserVo();

			ubuyUserVo.setPassport(TestDataManager.randomStr(10) + "passport");
			ubuyUserVo.setPassportIssuePlace(TestDataManager.randomStr(10)
					+ "passportIssuePlace");
			ubuyUserVo.setUserName(TestDataManager.getChineseName()
					+ "userName");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp placeOrder = SqTradingCallService
					.placeOrderWithUbuy(productBean, ubuyUserVo);

			long userId = placeOrder.getUserId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_042() {
		Logger.start(true, "代购神器交易下单,带有自提信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPickupType(productBean, autotest_goodsOwnerId, 0);
			
			long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_043() {
		Logger.start(true, "代购神器交易下单,带有purchaserIdcardId信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp placeOrder = SqTradingCallService
					.placeOrderWithPurchaserIdcardId(productBean,
							(long) TestDataManager.getRandomIntNum(5));

			long userId = placeOrder.getUserId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_044() {
		Logger.start(true, "代购神器交易下单,带有purchaserIdcardId信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp placeOrder = SqTradingCallService
					.placeOrderWithPurchaserIdcardId(productBean,
							(long) TestDataManager.getRandomIntNum(5));

			long userId = placeOrder.getUserId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_045() {
		Logger.start(true, "代购神器交易下单,修改身份证信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp placeOrder = SqTradingCallService
					.placeOrderWithPurchaserIdcardId(productBean,
							58L);

			long userId = placeOrder.getUserId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();// 支付订单
			
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrder.getTradingId());
			
			BigDecimal totalPrice = placeOrder.getPayableAmount();

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int) userId, BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService
					.sellerAcceptOrder(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			// 修改身份证信息
			SqTradingCallService.updateSqIdcardInfo(orderId, userId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_046() {
		Logger.start(true, "神器交易下单,带有分仓信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp placeOrder = SqTradingCallService
					.placeOrderWithWarehouseId(productBean,
							TestDataManager.getRandomIntNum(5));

			long userId = placeOrder.getUserId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_047() {
		Logger.start(true, "神器交易下单,部分发货，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp placeOrder = SqTradingCallService
					.placeOrderWithWarehouseId(productBean,
							TestDataManager.getRandomIntNum(5));

			long userId = placeOrder.getUserId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrder.getPayableAmount();
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrder.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int) userId, BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService
					.sellerAcceptOrder(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			// 发货
			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId, null, 1);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_048() {
		Logger.start(true, "神器交易下单,先部分发货， 再完整发货，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp placeOrder = SqTradingCallService
					.placeOrderWithWarehouseId(productBean,
							TestDataManager.getRandomIntNum(5));

			long userId = placeOrder.getUserId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrder.getPayableAmount();
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrder.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int) userId, BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService
					.sellerAcceptOrder(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			// 发货
			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId, null, 1);
			TradingSyncService.getSyncResult(orderId);

			// 再次发货
			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId,
					null, 2);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	// 神器交易分销只有支付成功，才会同步相关数据
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_049() {
		Logger.start(true, "神器交易分销下单，下单并支付，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false, false);
			
			long merchantId = productBean.getSellerId();
			HashMap<String, Object> map = SqDistributorService.createSelfPurchaseUser((long)merchantId, false);
			
			Long userId = ((Integer) map.get("userId")).longValue();
			Long distributorId = ((Integer) map.get("distributorId")).longValue();
			
			List<Long> firstLevelList = SqDistributorService
					.buildSqDistributorRelation(merchantId, 0,
							1, 0);
			List<Long> secondLevelList = SqDistributorService
					.buildSqDistributorRelation(merchantId, 1,
							2, firstLevelList.get(0));
			List<Long> thirdLevelList = SqDistributorService
					.buildSqDistributorRelation(merchantId, 2,
							1, secondLevelList.get(1));
			
			SqDistributorService.setDistributorConfig(merchantId, 3, true);
			SqDistributorService.buildSingleSqDistributorRelation(
					merchantId, 2, thirdLevelList.get(0), distributorId, 0);
			
			SqDistributorService.updateDistributorStatus(distributorId);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserId(productBean, userId);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_050() {
		Logger.start(true, "神器交易分销小店下单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createRetailShopProxychain(mchId, BigDecimal.TEN, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, mchId);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_051() {
		Logger.start(true, "神器交易下单，带有入境相关信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithEntryInfo(productBean);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_052() {
		Logger.start(true, "代购神器渠道商交易下单,包含虚拟库存，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithVStockCount(productBean, 2);

			long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					placeOrderResp.getPayableAmount().subtract(BigDecimal.ZERO).toString(),
					(int) userId, BigDecimal.ZERO.toPlainString());

			Logger.comment("前置数据准备结束");
			
			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_053() {
		Logger.start(true, "代购神器直销商核销虚拟库存订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, autotest_goodsOwnerId, 2);

			long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			TradingSyncService.getSyncResult(orderId);
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					placeOrderResp.getPayableAmount().subtract(BigDecimal.ZERO).toString(),
					(int) userId, BigDecimal.ZERO.toPlainString());
			
			Thread.sleep(5000);

			SqTradingCallService.stockIn(autotest_goodsOwnerId, productBean.getProductId(), 10);
			SqTradingCallService.sqStockChangeNotify(productBean);
			
			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_DGSQTradingSync_054() {
		Logger.start(true, "神器组团成功砍价团订单,核销虚拟库存,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);

			BargainGroupService.shenqiOpenGroup(bizId, productBean, true);

			// 参团
			TradingServiceResp placeOrder2 = BargainGroupService
					.shenqiJoinGroup(bizId, productBean, true);

			long orderId = placeOrder2.getOrderList().get(0).getOrderId();
			long userId = placeOrder2.getUserId();
			
			TradingSyncService.getSyncResult(orderId);

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, 3);
			
			Logger.comment("前置数据准备结束");
			
			Thread.sleep(5000);
			
			SqTradingCallService.ReduceSqProductStocks(orderId);
			
			SqTradingCallService.stockIn(autotest_goodsOwnerId, productBean.getRootProductId(), 10);
			SqTradingCallService.sqStockChangeNotify(productBean);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_055() {
		Logger.start(true, "代购神器申请退款，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false, false);
			
			TradingServiceResp placeOrderResp = SqTradingCallService
					.orderApplyRefund(productBean);
			
			Long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			Long userId = placeOrderResp.getUserId();
			
			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_056() {
		Logger.start(true, "代购神器退款成功，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false, false);
			
			TradingServiceResp placeOrderResp = SqTradingCallService
					.orderRefundSuccess(productBean);
			
			Long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			Long userId = placeOrderResp.getUserId();
			
			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_057() {
		Logger.start(true, "代购神器退款失败，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false, false);
			
			TradingServiceResp placeOrderResp = SqTradingCallService
					.orderRefundFailed(productBean);
			
			Long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			Long userId = placeOrderResp.getUserId();
			
			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_058() {
		Logger.start(true, "代购神器虚拟库存订单，包含一个虚拟库存商品，一个真实库存商品，虚拟商品全部退款，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = new AgentProductBean();
			
			String productId = DGSQBaseService.createAgentProduct(
					(int) autotest_goodsOwnerId, "autotest_goodsOwnerId", true,
					"CNY", true);
			
			productBean.setSellerId(autotest_goodsOwnerId);
			productBean.setSellerLoginId(new DGUserWapper().selectDGUserInfo(
					(int)autotest_goodsOwnerId).get(0).getLoginId());
			productBean.setProductId(productId);
			productBean.setRootProductId(productId);
			productBean.setCatalogList(DGSQBaseService.getCatalogIdList(productId));
			productBean.setRootCatalogList(DGSQBaseService.getCatalogIdList(productId));
			productBean.setGoodsOwnerId(autotest_goodsOwnerId);
			
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeVStockOrder4(productBean);
			
			Order order = placeOrderResp.getOrderList().get(0);

			Long userId = placeOrderResp.getUserId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			long orderId = order.getOrderId();

			//第一个订单下的商品列表
			List<OrderDetailPo> orderDetailPoList = order
					.getOrderDetailPoList();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());
			
			Thread.sleep(5000);
			
			String catalogId = orderDetailPoList.get(0).getCatalogId();
			int productCount = orderDetailPoList.get(0).getProductCount();
			
			HashMap<String, BigDecimal> map = RefundService
					.getShenqiRefundAmount(orderId, autotest_goodsOwnerId, catalogId,
							productCount);
			
			ConfirmApplyRefundReq req = RefundService.buildStandApplyRefundReq(orderId,
					autotest_goodsOwnerId, catalogId,
					map.get("maxRefundFreight"), map.get("maxRefundTax"),
					map.get("maxProductRefundAmount"), productCount);
			
			RefundService.applyRefundCall(req);
			
			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_059() {
		Logger.start(true, "代购神器交易下单,带有ProxyOrderId,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithProxyOrderId(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_060() {
		Logger.start(true, "代购神器交易下单,带有服务费税率,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithServiceRate(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_061() {
		Logger.start(true, "代购神器交易下单,更新商品sku,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithServiceRate(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			
			SqTradingCallService.updateOrderProductSku(orderId,
					productBean.getCatalogList().get(0), productBean);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_062() {
		Logger.start(true, "代购神器交易下单,发货后，修改发货时间,验证同步Mongo,ES数据");
		try {
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, autotest_goodsOwnerId);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			
			Long userId = resp.getUserId();
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					resp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					resp.getPayableAmount().subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());
			
			Thread.sleep(5000);
			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.sellerAcceptOrder(orderId);
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.delivery(orderId);
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.updateOrderDeliveryTime(orderId, productBean);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_063() {
		Logger.start(true, "神器订单货头添加备注,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp resp = SqTradingCallService.placeOrder(productBean, autotest_goodsOwnerId);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();
			
			Thread.sleep(2000);
			
			SqTradingCallService.operateSellerMemo(orderId, autotest_goodsOwnerId, 0);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			
			Thread.sleep(3000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_064() {
		Logger.start(true, "神器订单中间商更新备注,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false);

			TradingServiceResp resp = SqTradingCallService.placeOrder(productBean, autotest_goodsOwnerId);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();
			
			Thread.sleep(2000);
			
			SqTradingCallService.operateSellerMemo(orderId, productBean.getSellerIds().get(1), 1);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_065() {
		Logger.start(true, "神器订单中间商更新备注,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);

			TradingServiceResp resp = SqTradingCallService.placeOrder(productBean, autotest_goodsOwnerId);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();
			
			Thread.sleep(2000);
			
			SqTradingCallService.operateSellerMemo(orderId, productBean.getSellerIds().get(1), 1);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_066() {
		Logger.start(true, "神器订单下单，触发风控，支持线下支付，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			TradingServiceResp resp = SqTradingCallService
					.placeOrderTriggerRiskControlWithSupportOfflinePay(productBean);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_067() {
		Logger.start(true, "神器订单下单，买家同意线下支付，修改支付凭证，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp resp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, productBean.getCurrency(),
							new BigDecimal("0.165321"), true);

			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();

			SqTradingCallService.payOrder(userId, resp.getTradingId(),
					"wxsqBuyer", "200");

			// 修改支付凭证
			SqTradingCallService.UpdateVoucher(resp.getMainOrderId(), userId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_068() {
		Logger.start(true, "神器订单下单，组合商品，带各种优惠，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int mchId = DGSQBaseService.createIndependenceMch("USA");
			
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeMultiComposeProductOrderWithIntegral((long)mchId);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), (int)userId,
					BigDecimal.ZERO.toPlainString());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			
			Thread.sleep(3000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_069() {
		Logger.start(true, "代购神器交易下单,带有成本价商品，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_070() {
		Logger.start(true, "代购神器交易下单,推送海关清关状态，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) 500041475, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 500041475);

			long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			
			// 推送海关清关状态
			OpenApiBizCallService.SqPushSqOrderCustomsClearanceStatus(orderId, productBean.getGoodsOwnerId());
			TradingSyncService.getSyncResult(orderId);
			
			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_071() {
		Logger.start(true, "代购神器交易下单,推送商品额外信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			
			// 推送商品额外信息
			OpenApiBizCallService.sqPushSqOrderExtInfo(orderId, productBean.getGoodsOwnerId(), "sku111");
			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_072() {
		Logger.start(true, "神器订单下单，组合商品，带各种优惠，推送组合商品额外信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createComposeProductProxychain(
							(int) autotest_goodsOwnerId, false, false);
			
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeComposeProductOrder(productBean, autotest_goodsOwnerId);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), (int)userId,
					BigDecimal.ZERO.toPlainString());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			
			PackageInfoByCatalogIdListResponse response = SqTradingProductService
					.getPackageInfoByCatalogIdList(
							productBean.getGoodsOwnerId(),
							Arrays.asList(placeOrderResp.getOrderList().get(0)
									.getOrderDetailPoList().get(0)
									.getCatalogId()));

			String subSkuId = response.getProductPackageList().get(0)
					.getSubCatalogList().get(0).getSkuId();
			
			// 推送商品额外信息
			OpenApiBizCallService.sqPushSqOrderExtInfo(orderId,
					productBean.getGoodsOwnerId(), subSkuId);
			TradingSyncService.getSyncResult(orderId);
			
			Thread.sleep(5000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_073() {
		Logger.start(true, "代购神器订单使用了积分，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int mchId = DGSQBaseService.createIndependenceMch("USA");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) mchId, 0, false);

			GodPointsService.saveCreditPolicyReq((long) mchId);
			Thread.sleep(500);

			GodPointsService.sendCredit((long) mchId, 20238699L);
			Thread.sleep(500);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithIntegral(productBean, mchId, 10L);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_074() {
		Logger.start(true, "代购神器交易下单，主商品加换购商品,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithExchangeBuy(productBean, productBean.getGoodsOwnerId());

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_075() {
		Logger.start(true, "中免大会员订单使用了积分，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createMultiCodeProxychain((int) cdfMembergoodsOwnerId,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithCDFMember(productBean, cdfMembergoodsOwnerId, 10L);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_076() {
		Logger.start(true, "代购神器交易下单,被海关风控，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) 500041475, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithBlackList(productBean, 3L, 500041475L);

			long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());
			
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int) userId, BigDecimal.ZERO.toPlainString());
			
			Thread.sleep(5000);
			
			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_077() {
		Logger.start(true, "神器订单下单，组合商品，使用积分，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			int mchId = DGSQBaseService.createIndependenceMch("USA");
			
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeMultiComposeProductOrderWithIntegral(mchId);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), (int)userId,
					BigDecimal.ZERO.toPlainString());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_078() {
		Logger.start(true, "中免大会员订单下单，组合商品，使用积分，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeCDFMemberComposeProductOrder(cdfMembergoodsOwnerId, 100L);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_079() {
		Logger.start(true, "神器订单下单，买手确认线下支付，接单后并取消，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp resp = SqTradingCallService.placeOrder(
					productBean, BigDecimal.ZERO, autotest_goodsOwnerId,
					productBean.getCurrency(), new BigDecimal("0.165321"), true);
			
			long orderId = resp.getOrderList().get(0).getOrderId();
			long userId = resp.getUserId();
			
			SqTradingCallService.payOrder(userId, resp.getTradingId(), "wxsqBuyer", "200");
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.confirmOfflinePay(orderId, autotest_goodsOwnerId);
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.cancelOrder(orderId, CancelOrderTypeEnum.SELLER_CANCEL_ORDER, userId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_080() {
		Logger.start(true, "代购神器多段发货,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);
			
			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			Thread.sleep(3000);
			
			// 神器订单多段发货
			SqPretradeService.multiDelivery(goodsOwnerId, orderId);
			Thread.sleep(3000);

			Logger.comment("前置数据准备结束");

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_081() {
		Logger.start(true, "代购神器，使用代币余额支付，验证同步Mongo，ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain((int)virtualCoinGoodsOwnerId, 1, false, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserIdAndGoodsOwnerIdAndCurrency(
							productBean, productBean.getSellerId(),
							virtualCoinGoodsOwnerId, productBean.getCurrency());
			
			Long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long tradingId = placeOrderResp.getTradingId();
			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			// 充值代币
			SqPretradeService.virtualCoinCharge(virtualCoinGoodsOwnerId,
					productBean.getSellerId(), useAccountAmount);

			// 支付订单
			SqTradingCallService.payOrderWithVirtualCoin(productBean.getSellerId(), tradingId, useAccountAmount);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			Logger.comment("前置数据准备结束");

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_082() {
		Logger.start(true, "神器创建砍价团参团订单,使用代币支付，砍价团通知组团失败,ORDER_BIZ指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain((int)virtualCoinGoodsOwnerId, 1, false, false);

			BargainGroupService.shenqiOpenGroupWithVirtualCoin(bizId, productBean, false);

			// 参团
			TradingServiceResp placeOrder2 = BargainGroupService
					.shenqiJoinGroupWithVirtualCoin(bizId, productBean, false);

			long orderId = placeOrder2.getOrderList().get(0).getOrderId();
			long userId = placeOrder2.getUserId();

			Logger.comment("前置数据准备结束");

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, -3);
			
			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_083() {
		Logger.start(true, "一品多码商品下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createMultiCodeProxychain((int) multiCDFCodeGoodsOwnerId, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeMultiCDFCodeOrder(productBean, multiCDFCodeGoodsOwnerId);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_084() {
		Logger.start(true, "一品多码商品下单，订单支付后退款，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createMultiCodeProxychain((int) multiCDFCodeGoodsOwnerId, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeMultiCDFCodeOrder(productBean, multiCDFCodeGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();
			
			RefundService.createFullRefundSuccess(orderId,
					multiCDFCodeGoodsOwnerId, paymentId, userId);
			
			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_085() {
		Logger.start(true, "神器一品多码商品创建砍价团参团订单,砍价团通知组团成功,ORDER_BIZ指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createMultiCodeProxychain((int) multiCDFCodeGoodsOwnerId, false);

			BargainGroupService.shenqiMultiCodeOpenGroup(bizId, productBean);

			// 参团
			TradingServiceResp placeOrder2 = BargainGroupService
					.shenqiMultiCodeJoinGroup(bizId, productBean);

			long orderId = placeOrder2.getOrderList().get(0).getOrderId();
			long userId = placeOrder2.getUserId();

			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, 3);
			
			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_086() {
		Logger.start(true, "神器一品多码商品创建砍价团参团订单，砍价团通知组团失败,ORDER_BIZ指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createMultiCodeProxychain((int) multiCDFCodeGoodsOwnerId, false);

			BargainGroupService.shenqiMultiCodeOpenGroup(bizId, productBean);

			// 参团
			TradingServiceResp placeOrder2 = BargainGroupService
					.shenqiMultiCodeJoinGroup(bizId, productBean);

			long orderId = placeOrder2.getOrderList().get(0).getOrderId();
			long userId = placeOrder2.getUserId();

			Logger.comment("前置数据准备结束");

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, -3);
			
			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_087() {
		Logger.start(true, "一品多码组合商品下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeMultiCodeComposeProductOrder(multiCDFCodeGoodsOwnerId);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_088() {
		Logger.start(true, "直播订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserClick(productBean, autotest_goodsOwnerId, false);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);
			
			SqTradingMqService.updateLiveOrder(true, orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_089() {
		Logger.start(true, "代购神器交易下单支付找人代付，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			Logger.comment("前置数据准备结束");

			// 支付订单
			long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), true);

			Thread.sleep(3000);

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_090() {
		Logger.start(true, "代购神器组合商品预订订单下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createComposeProductProxychain(
							(int) multiCDFCodeGoodsOwnerId, false, true);
			
			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService
					.placeComposeProductBookingOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_091() {
		Logger.start(true, "代购神器支付定金订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService
					.placeBookingOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			
			// 支付定金
			long thirdTradingId = SqTradingBookingOrderCallService
					.payBookingOrder(placeOrderResp.getUserId(),
							placeOrderResp.getTradingId());
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int) placeOrderResp.getUserId(),
					BigDecimal.ZERO.toPlainString(), productBean.getCurrency());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_092() {
		Logger.start(true, "代购神器支付定金全款订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService
					.placeSecondConfirmOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			
			// 支付全款
			long thirdTradingId = SqTradingBookingOrderCallService
					.paySecondConfirmOrder(placeOrderResp.getUserId(),
							placeOrderResp.getTradingId());
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int) placeOrderResp.getUserId(),
					BigDecimal.ZERO.toPlainString(), productBean.getCurrency());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	// 添加商品时，真实库存设为0
	public void Tc_DGSQTradingSync_093() {
		Logger.start(true, "代购神器直销商使用兑换券，核销虚拟库存订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithExchangeCoupon(productBean, productBean.getSellerId());

			long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			TradingSyncService.getSyncResult(orderId);
			
			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					placeOrderResp.getPayableAmount().subtract(BigDecimal.ZERO).toString(),
					(int) userId, BigDecimal.ZERO.toPlainString());
			
			Thread.sleep(5000);

			SqTradingCallService.stockIn(autotest_goodsOwnerId, productBean.getProductId(), 10);
			SqTradingCallService.sqStockChangeNotify(productBean);
			
			Logger.comment("前置数据准备结束");
			
			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_094() {
		Logger.start(true, "代购神器交易导购订单下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeGuideOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_095() {
		Logger.start(true, "代购神器交易下单,买家自提，接单后，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPickupType(productBean, autotest_goodsOwnerId, 0);
			
			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId, orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_096() {
		Logger.start(true, "代购神器交易下单,商家通知自提，发货后，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPickupType(productBean, autotest_goodsOwnerId, 1);
			
			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);
			
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId, 1234L, null);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_097() {
		Logger.start(true, "代购神器交易下单,商家通知自提，自提点确认收货，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPickupType(productBean, autotest_goodsOwnerId, 1);
			
			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);
			
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId, 1234L, null);
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.pickupConfirmReceiving(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_098() {
		Logger.start(true, "代购神器交易下单,商家通知自提，自提订单核销，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPickupType(productBean, autotest_goodsOwnerId, 1);
			
			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);
			
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId, 1234L, null);
			TradingSyncService.getSyncResult(orderId);
			
			SqTradingCallService.pickupConfirmReceiving(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			wapper.clearCache();
			
			String pickUpCode = wapper.selectPickInStorebyOrderId(orderId)
					.get(0).getPickupCode();

			SqTradingCallService.pickUpCodeWriteOff(autotest_goodsOwnerId,
					orderId, pickUpCode);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_099() {
		Logger.start(true, "代购神器交易下单,买家预约自提，核销后，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPickupType(productBean, autotest_goodsOwnerId, 0);
			
			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);
			
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			
			wapper.clearCache();

			SqTradingCallService.pickUpCodeWriteOff(autotest_goodsOwnerId,
					orderId, null);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_100() {
		Logger.start(true, "代购神器支付定金全款订单，二次确认时修改自提信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService
					.placePickupStoreSecondConfirmOrder(productBean);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			
			// 支付全款
			long thirdTradingId = SqTradingBookingOrderCallService
					.paySecondConfirmOrder(placeOrderResp.getUserId(),
							placeOrderResp.getTradingId());
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					(int) placeOrderResp.getUserId(),
					BigDecimal.ZERO.toPlainString(), productBean.getCurrency());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_DGSQTradingSync_101() {
		Logger.start(true, "代购神器使用资格券下单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createMultiCodeProxychain((int) shenqiRiskControlGoodsOwnerId,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithCdfVipCode(productBean, shenqiRiskControlGoodsOwnerId);

			long userId = placeOrderResp.getUserId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					placeOrderResp.getPayableAmount().subtract(BigDecimal.ZERO).toString(),
					(int)userId, BigDecimal.ZERO.toPlainString());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verifyDGSQ(orderId, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	// @Test
	// @Category(P1.class)
	// @TestCase
	// public void Tc_TradingSync_062() {
	// Logger.start(true, "测试");
	// try {
	// // 创建订单
	// Logger.comment("前置数据准备");
	//
	// TradingServiceResp placeOrder = TradingCallService
	// .placeEngageOrder(false);
	//
	// long userId = placeOrder.getUserId();
	// long tradingId = placeOrder.getTradingId();
	// long sellerId = placeOrder.getOrderList().get(0).getSellerId();
	// BigDecimal earnestAmount =
	// placeOrder.getOrderList().get(0).getOrderPo().getEarnestAmount();
	// long orderId = placeOrder.getOrderList().get(0).getOrderId();
	//
	// TradingCallService.payEngageOrder(userId, earnestAmount, tradingId);
	// TradingServiceResp fullPlaceOrder =
	// TradingCallService.placeFullPaidOrder(userId, orderId);
	//
	//
	// List<Order> engageOrder = fullPlaceOrder.getOrderList().stream()
	// .filter(o -> o.getOrderId() == orderId).collect(Collectors.toList());
	//
	// Logger.comment("前置数据准备结束");
	//
	// } catch (Exception e) {
	// Logger.fail(e);
	// }
	// }

	public static void main(String[] args) throws ClientProtocolException,
			IOException {
		//手动同步一次商品
//		YmatouEasyCall getProdCall = new YmatouEasyCall("", "GET", null);
//
//		getProdCall
//				.setUrl("http://productsync.iapi.ymatou.com/api/cache/mongocrud?ActionType=CreateProduct&ActivityId=0&TransactionId=322487428&ProductId="
//						+ "p1651066");
//		getProdCall.setData("");
//		getProdCall.callService();
		
		TradingSyncService.verifyDGSQ(14178370783L, 26080783L);
	}
}